<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>menubase.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_menubase.js.html">menubase.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Definition of the MenuBase class.
<a name="line17"></a> *
<a name="line18"></a> */
<a name="line19"></a>
<a name="line20"></a>goog.provide(&#39;goog.ui.MenuBase&#39;);
<a name="line21"></a>
<a name="line22"></a>goog.require(&#39;goog.events.EventHandler&#39;);
<a name="line23"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line24"></a>goog.require(&#39;goog.events.KeyHandler&#39;);
<a name="line25"></a>goog.require(&#39;goog.events.KeyHandler.EventType&#39;);
<a name="line26"></a>goog.require(&#39;goog.ui.Popup&#39;);
<a name="line27"></a>
<a name="line28"></a>
<a name="line29"></a>
<a name="line30"></a>/**
<a name="line31"></a> * The MenuBase class provides an abstract base class for different
<a name="line32"></a> * implementations of menu controls.
<a name="line33"></a> *
<a name="line34"></a> * @param {Element=} opt_element A DOM element for the popup.
<a name="line35"></a> * @deprecated Use goog.ui.Menu.
<a name="line36"></a> * @constructor
<a name="line37"></a> * @extends {goog.ui.Popup}
<a name="line38"></a> */
<a name="line39"></a>goog.ui.MenuBase = function(opt_element) {
<a name="line40"></a>  goog.ui.Popup.call(this, opt_element);
<a name="line41"></a>
<a name="line42"></a>  /**
<a name="line43"></a>   * Event handler for simplifiying adding/removing listeners.
<a name="line44"></a>   * @type {goog.events.EventHandler}
<a name="line45"></a>   * @private
<a name="line46"></a>   */
<a name="line47"></a>  this.eventHandler_ = new goog.events.EventHandler(this);
<a name="line48"></a>
<a name="line49"></a>  /**
<a name="line50"></a>   * KeyHandler to cope with the vagaries of cross-browser key events.
<a name="line51"></a>   * @type {goog.events.KeyHandler}
<a name="line52"></a>   * @private
<a name="line53"></a>   */
<a name="line54"></a>  this.keyHandler_ = new goog.events.KeyHandler(this.getElement());
<a name="line55"></a>};
<a name="line56"></a>goog.inherits(goog.ui.MenuBase, goog.ui.Popup);
<a name="line57"></a>
<a name="line58"></a>
<a name="line59"></a>/**
<a name="line60"></a> * Events fired by the Menu
<a name="line61"></a> */
<a name="line62"></a>goog.ui.MenuBase.Events = {};
<a name="line63"></a>
<a name="line64"></a>
<a name="line65"></a>/**
<a name="line66"></a> * Event fired by the Menu when an item is &quot;clicked&quot;.
<a name="line67"></a> */
<a name="line68"></a>goog.ui.MenuBase.Events.ITEM_ACTION = &#39;itemaction&#39;;
<a name="line69"></a>
<a name="line70"></a>
<a name="line71"></a>/** @override */
<a name="line72"></a>goog.ui.MenuBase.prototype.disposeInternal = function() {
<a name="line73"></a>  goog.ui.MenuBase.superClass_.disposeInternal.call(this);
<a name="line74"></a>  this.eventHandler_.dispose();
<a name="line75"></a>  this.keyHandler_.dispose();
<a name="line76"></a>};
<a name="line77"></a>
<a name="line78"></a>
<a name="line79"></a>/**
<a name="line80"></a> * Called after the menu is shown. Derived classes can override to hook this
<a name="line81"></a> * event but should make sure to call the parent class method.
<a name="line82"></a> *
<a name="line83"></a> * @protected
<a name="line84"></a> * @suppress {underscore}
<a name="line85"></a> * @override
<a name="line86"></a> */
<a name="line87"></a>goog.ui.MenuBase.prototype.onShow_ = function() {
<a name="line88"></a>  goog.ui.MenuBase.superClass_.onShow_.call(this);
<a name="line89"></a>
<a name="line90"></a>  // register common event handlers for derived classes
<a name="line91"></a>  var el = this.getElement();
<a name="line92"></a>  this.eventHandler_.listen(
<a name="line93"></a>      el, goog.events.EventType.MOUSEOVER, this.onMouseOver);
<a name="line94"></a>  this.eventHandler_.listen(
<a name="line95"></a>      el, goog.events.EventType.MOUSEOUT, this.onMouseOut);
<a name="line96"></a>  this.eventHandler_.listen(
<a name="line97"></a>      el, goog.events.EventType.MOUSEDOWN, this.onMouseDown);
<a name="line98"></a>  this.eventHandler_.listen(
<a name="line99"></a>      el, goog.events.EventType.MOUSEUP, this.onMouseUp);
<a name="line100"></a>
<a name="line101"></a>  this.eventHandler_.listen(
<a name="line102"></a>      this.keyHandler_,
<a name="line103"></a>      goog.events.KeyHandler.EventType.KEY,
<a name="line104"></a>      this.onKeyDown);
<a name="line105"></a>};
<a name="line106"></a>
<a name="line107"></a>
<a name="line108"></a>/**
<a name="line109"></a> * Called after the menu is hidden. Derived classes can override to hook this
<a name="line110"></a> * event but should make sure to call the parent class method.
<a name="line111"></a> * @param {Object=} opt_target Target of the event causing the hide.
<a name="line112"></a> * @protected
<a name="line113"></a> * @suppress {underscore}
<a name="line114"></a> * @override
<a name="line115"></a> */
<a name="line116"></a>goog.ui.MenuBase.prototype.onHide_ = function(opt_target) {
<a name="line117"></a>  goog.ui.MenuBase.superClass_.onHide_.call(this, opt_target);
<a name="line118"></a>
<a name="line119"></a>  // remove listeners when hidden
<a name="line120"></a>  this.eventHandler_.removeAll();
<a name="line121"></a>};
<a name="line122"></a>
<a name="line123"></a>
<a name="line124"></a>/**
<a name="line125"></a> * Returns the selected item
<a name="line126"></a> *
<a name="line127"></a> * @return {Object} The item selected or null if no item is selected.
<a name="line128"></a> */
<a name="line129"></a>goog.ui.MenuBase.prototype.getSelectedItem = function() {
<a name="line130"></a>  return null;
<a name="line131"></a>};
<a name="line132"></a>
<a name="line133"></a>
<a name="line134"></a>/**
<a name="line135"></a> * Sets the selected item
<a name="line136"></a> *
<a name="line137"></a> * @param {Object} item The item to select. The type of this item is specific
<a name="line138"></a> *     to the menu class.
<a name="line139"></a> */
<a name="line140"></a>goog.ui.MenuBase.prototype.setSelectedItem = function(item) {
<a name="line141"></a>};
<a name="line142"></a>
<a name="line143"></a>
<a name="line144"></a>/**
<a name="line145"></a> * Mouse over handler for the menu. Derived classes should override.
<a name="line146"></a> *
<a name="line147"></a> * @param {goog.events.Event} e The event object.
<a name="line148"></a> * @protected
<a name="line149"></a> */
<a name="line150"></a>goog.ui.MenuBase.prototype.onMouseOver = function(e) {
<a name="line151"></a>};
<a name="line152"></a>
<a name="line153"></a>
<a name="line154"></a>/**
<a name="line155"></a> * Mouse out handler for the menu. Derived classes should override.
<a name="line156"></a> *
<a name="line157"></a> * @param {goog.events.Event} e The event object.
<a name="line158"></a> * @protected
<a name="line159"></a> */
<a name="line160"></a>goog.ui.MenuBase.prototype.onMouseOut = function(e) {
<a name="line161"></a>};
<a name="line162"></a>
<a name="line163"></a>
<a name="line164"></a>/**
<a name="line165"></a> * Mouse down handler for the menu. Derived classes should override.
<a name="line166"></a> *
<a name="line167"></a> * @param {!goog.events.Event} e The event object.
<a name="line168"></a> * @protected
<a name="line169"></a> */
<a name="line170"></a>goog.ui.MenuBase.prototype.onMouseDown = function(e) {
<a name="line171"></a>};
<a name="line172"></a>
<a name="line173"></a>
<a name="line174"></a>/**
<a name="line175"></a> * Mouse up handler for the menu. Derived classes should override.
<a name="line176"></a> *
<a name="line177"></a> * @param {goog.events.Event} e The event object.
<a name="line178"></a> * @protected
<a name="line179"></a> */
<a name="line180"></a>goog.ui.MenuBase.prototype.onMouseUp = function(e) {
<a name="line181"></a>};
<a name="line182"></a>
<a name="line183"></a>
<a name="line184"></a>/**
<a name="line185"></a> * Key down handler for the menu. Derived classes should override.
<a name="line186"></a> *
<a name="line187"></a> * @param {goog.events.KeyEvent} e The event object.
<a name="line188"></a> * @protected
<a name="line189"></a> */
<a name="line190"></a>goog.ui.MenuBase.prototype.onKeyDown = function(e) {
<a name="line191"></a>};
</pre>


</body>
</html>
